export const formatDuration = (duration) => {
  // 转分
  let min = Math.ceil(duration / 1000 / 60);
  min = min < 10 ? '0' + min : min;
  // 秒
  let sec = Math.ceil((duration / 1000) % 60);
  sec = sec < 10 ? '0' + sec : sec;
  return min + ':' + sec;
}

export const formatCount = (count) => {
  if (count < 0) {
    return;
  } else if (count < 10000) {
    return count;
  } else if (Math.floor(count / 10000) < 10000) {
    return Math.floor(count / 1000) / 10 + '万';
  } else {
    return Math.floor(count / 10000000) / 10 + '亿';
  }
}

export function getSizeImage(imgUrl, size) {
  return `${imgUrl}?param=${size}x${size}`;
}

// 对象数组去重，根据id
export function duplication(arr){
  let map = new Map();
  let res = [];
  for(let obj of arr){
    if(!map.has(obj.id)){
      map.set(obj.id,1);
      res.push(obj);
    }
  }
  return res;
}